<?php



    if(empty($_GET['p'])){
        $_GET['p'] = 1;
    };
    $cur_page = $_GET['p'];
    $per_page = 3;
    $show_page = 5;
    $offset = ($cur_page - 1)*$per_page;

    include_once(LIB_PATH.'pages.php');
    $pages = getPages($cur_page,$per_page,$show_page,'news',$link);
    //echo $pages;die;

    $data = getSelect('news`,`cate','`news`.`type`=`cate`.`id`',$offset.','.$per_page,'`id` desc','`news`.*,`cate`.`name`');
    // $sql = "select `news`.*,`cate`.`name` from `news`,`cate` where `news`.`type`=`cate`.`id` order by `id` desc limit $offset,$per_page";

    // $result = mysqli_query($link,$sql);


    // while ($arr = mysqli_fetch_assoc($result)){
    //     $data[] = $arr;
    // };


    if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {

        print_r(json_encode(array('data'=>$data,'pages'=>$pages)));die;

    };

?>